<div class="row-fluid lines" style="padding-top: 20px;padding-bottom: 20px">
<div  style="padding-left: 20px;" >
	<input type="hidden" name="user" value="<?php echo ucfirst($this->common_model->get_username_id($this->session->userdata('user_id')));?>" readonly />
	<span style="font-size: 21px">My Projects</span>
	<br />
	<span style="font-size: 14px" class="muted">
	<?php
	$now = new DateTime();
	$hr = $now->format('H'); 
	if($hr > 12 AND $hr < 17){
		echo "Good Afternoon";
	}elseif($hr >= 17 ){
		echo "Good Evening";
	}	
	else {
		echo "Good Morning";
	}
	?> 
	<?php echo ucfirst($this->common_model->get_username_id($this->session->userdata('user_id')));?></span>
	<br>
	
</div>
</div>
<br />
<div class="row-fluid">
<table class="table" id="example">
	<thead>
		<tr>
			<th>Project Name</th>
			<th>Due Date</th>
			<th>Completed</th>
			<th>Action</th>
		</tr>
	</thead>
	<?php foreach($my_projects as $my_project){?>
	<tr>
		<td><?php echo $my_project->name?></td>
		<td><?php echo $my_project->end_date?></td>		
		<td><?php echo round($this->task_model->get_percentage_by_projectid($my_project->id)).' %';?></td>
		<td>
		
			<?php 
	// get fav
	$fav = $this->task_model->get_fav_project($my_project->id,$this->session->userdata('user_id'));	
	if(count($fav)==0){
	?>
	<a href="javascript:void(0)"  id="fav" onclick="add_fav_project(<?php echo $my_project->id;?>)"><i class="icon-star-empty" id="star"></i> </a>
	<?php }else{?>	
	<a href="javascript:void(0)"  id="nofav" onclick="remove_fav_project(<?php echo $my_project->id;?>)" ><i class="icon-star" id="star"></i> </a>
	<?php }?>
			
		</td>
	</tr>
	<?php }?>
</table>
</div>
<script type="text/javascript">
function add_fav_project(pId) {		
		$.post('<?= site_url("user/tasks/add_fav_project");?>',{id:pId}, function(data) {						
			//$('#fav').hide();
			//$('#nofav').show();
			location.reload();
	});
	}
	function remove_fav_project(pId) {	
		$.post('<?= site_url("user/tasks/remove_fav_project");?>',{id:pId}, function(data) {			
			//$('#fav').show();
			//$('#nofav').hide();
			location.reload();
	});
	}
</script>